<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>

<!DOCTYPE html>
<html lang="zh-CN">
<head>

<c:set var="ctx" value="${pageContext.request.contextPath}" />
<title>档案超期提醒</title>
<jsp:include page="../../import.jsp" flush="true" />
<script type="text/javascript" src="<%=path %>/resource/lib/plugins/ajaxfileupload.js"></script>
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div class="searchArea">
		<!-- 搜索表单开始 -->
		<form id="searchBar" enctype = "multipart/form-data">
			<div class="fieldset1 clearFix">
				<div class="FXBR">
					<div class="fieldBox">
						<div class="label">承租人名称</div>
						<div class="field">
							<input type="text" id="cstNm" name="cstNm" class="ui-textbox" ligerui="width: 160" value="">
						</div>
					</div>
					<div class="fieldBox">
						<div class="label">合同编号</div>
						<div class="field">
							<input type="text" id="contractNo" name="contractNo" class="ui-textbox" ligerui="width: 160" value="">
						</div>
					</div>
					<div class="fieldBox">
						<div class="label">支付表号</div>
						<div class="field">
							<input type="text" id="paySchNo" name="paySchNo" class="ui-textbox" ligerui="width: 160" value="">
						</div>
					</div>
<!-- 					<div class="fieldBox"> -->
<!-- 	                        <div class="label">事业部</div> -->
<!-- 	                        <div class="field"> -->
<!-- 	                            <input name="bussDepartment" id="bussDepartment" data-value="" placeholder="请选择" ltype="combobox"> -->
<!-- 	                        </div> -->
<!-- 					</div> -->
<!-- 					<div class="fieldBox"> -->
<!--                         <div class="label">省公司</div> -->
<!--                         <div class="field"> -->
<!--                             <input  name="proCompany" id="proCompany" data-value="" placeholder="请选择" ltype="combobox"> -->
<!--                         </div> -->
<!--                     </div> -->
					<div class="fieldBox">
							<div class="label">事业部</div>
							<div class="field">
								<select id="buOrgCd"  name="buOrgCd"  ligerui="width: 160">
									<option value="">请选择</option>
									<c:forEach items="${buOrgCdList}" var="item">
										<option value="${item.key}">${item.value}</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">省公司</div>
							<div class="field">
								<select id="cstMgrOrgCd"  name="cstMgrOrgCd"  ligerui="width: 140">
									<option value="">请选择</option>
									<c:forEach items="${prList}" var="item">
										<option value="${item.key}">${item.value}</option>
									</c:forEach>
								</select>
							</div>
						</div>
					<div class="fieldBox">
						<div class="label">资产包</div>
		                    <div class="field">
                                <input id="upfile" name="upfile" style="width:150px" type="file">
								<span class="sq-button sq-button-hasicon"  onclick="ReadExcel();"><i class="sqBtnIco_9"></i>读取</span>  
								<span>
									<a id="upmodel" style="color:blue;text-decoration:underline;" href="<%=path %>/resource/template/reffile/paycddemo.xls" />模板样例下载</a>&nbsp;&nbsp;&nbsp;&nbsp; 
		                        </span>
		                        <input name="paySchCds" id="paySchCds" type="text" /> <!--value="${paySchCds}"-->
		                    </div>
						</div>
					</div>
					<div class="fieldBox">
						<div class="label">权证名称</div>
						<div class="field">
							<input name="searchCodeGrpCd" id="searchCodeGrpCd"  onclick="applyInvoice();"  type="text" ligerui="width: 160" >
<!--                                validate="{required:true}" -->
                        	<div class="combo_itemList_wrap"></div>
						</div>
					</div>
				</div>
				<div class="clearFix"></div>
				<!-- 表单按钮 -->
				<div class="btnsBox formBtns notRight">
					<span id="searchBtn" class="sq-button-round">查询</span>
					<span id="clearBtn" class="sq-button-round" onclick="clearBtnEvent();">清空</span>
					<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
					<span id="downBtn" class="sq-button-round" onclick="downloadBtnEvent();">批量下载</span>
	            </div>
			</div>
		</form>
		<!-- 搜索表单结束 -->
	</div>
	<!-- 列表显示块 -->
	<div id="ligergrid1" class="sq-grid"></div>
</div>

<div  style="display:none">
	<div id= "configDilog" >
	   <form id="mainGoodsCd_formSet">
		<div class="fieldset1 tabel_col clearFix">
			<div class="fieldBox col_100_auto">
				<div class="label">主货物大类</div>
				<div class="field">
					<select name="mainGoodsCd" id="mainGoodsCd" data-value=" " onchange="getGoods();">
						<option value=" " checked >请选择</option>
						<c:forEach items="${mainGdsTypCdList }" var="kv">
							<option value="${kv.key }">${kv.value }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			
			<div class="fieldBox col_100_auto">
				<div class="label">主运输货物</div>
				<div class="field">
					<select name="goods" id="goods" data-value=" " onchange="checkGoods();">
					</select>
				</div>
			</div>
			
		</div>
	 </form>
	</div>
</div>

<script type="text/javascript">
	var pageInApp={
		flag:false //tab页验证关闭
	};//to下一级子窗口 接口
	var pageInTab=null;//页签
	var loadedTabs=[];//页签
	var grid = null;
	$(function () {
		$("#paySchCds").css('display','none');
	    initForm();//初始化表单
	    initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
	    searchBtnEvent();//查询按钮事件
	    clearBtnEvent();//清空按钮
	});
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		return data;
	}
	
<%-- 	初始化列表  url:'<%=path%>///warrant/warrantfilemanage/initList.do', --%>

// 	var grid = null, form = null,mainGoodsCdform =null;
// 	 $(function () {
// 	    	mainGoodsCdform = $("#mainGoodsCd_formSet").ligerForm();
// 	 });
	function initGrid(){
		$("#ligergrid1").ligerGrid({
			url:'<%=path%>/warrant/warrantfilemanage/initListOverdue.do',
			method:'get',
			parms:getSearchParams(),
			columns:[
				{ display: '承租人姓名',name: 'cstNm', minWidth: 30 , align:'center', enabledSort:true},
				{ display: '合同编号', name: 'contractNo', minWidth: 180 , align:'center', enabledSort:true},
				{ display: '支付表号', name: 'paySchNo', minWidth: 180 , align:'center', enabledSort:true},
				{ display: '放款时间', name: 'actPayTm', width: 100, align:'center', enabledSort:true},
				{ display: '事业部', name: 'buOrgCdNm', width: 120 , enabledSort:true},
				{ display: '省公司', name: 'prOrgCdNm', width: 120 , enabledSort:true},
				{ display: '电子版归档状态', name: 'eleStorageStatusNm', width: 80, align:'center', enabledSort:true},
				{ display: '纸质归档状态', name: 'storageStatusNm', width: 100, align:'center', enabledSort:true},
				{ display:'操作',isSort:false,width:100,align:'center',
					render:function(rowdata, rowindex, value, column) {
	            		return '<a onclick="toGetPath('+"'"+rowdata.contractNo+"'"+')" >下载</a>';
	            	}	
				}
			],
			pageSize:10,
			root:'rows',
			record:'total',
			hideLoadButton:false,
			width:'100%',
			height:'100%',
			heightDiff:-2,
			checkbox:true,//列表是否有选择框
			rownumbers:true,//列表是否有行号
			frozen: false,
            allowUnSelectRow: true,
            alternatingRow: false,
            onBeforeShowData: function () {
                var grid = this;
                grid.collapsedRows = [];
            }
		});
		grid = liger.get("ligergrid1");
		grid.setHeight(100);
		//grid.options.isSingleCheck = true;//列表是否为单选
	}
	
	

	
	//清空按钮事件
	function clearBtnEvent(){
		$("#clearBtn").click(function(event) {
			$("#resetBtn").click();  //重置 input-text
			var form = liger.get("searchBar");
			form.setData({  //重置select等特殊表单
				"buOrgCd":"",//事业部
				"cstMgrOrgCd":""//省公司
			});
		});
	}
	//查询按钮事件
	function searchBtnEvent(){
		$("#searchBtn").click(function(event) {
			var form = ""; 
			form= new liger.get("searchBar");
			var data = form.getData();
// 			alert(JSON.stringify(data));
			for (name in data){
				grid.setParm(name,data[name]);
			};
			grid.reload();
		});
	}
	
	
	//导出信息
	function downloadBtnEvent(){
		var form = new liger.get("searchBar");
		var grid = liger.get("ligergrid1");
		var selectedRows = grid.getSelectedRows();
		var pkIds = new Array();
		for(var i=0;i<selectedRows.length;i++){
			var pkId = "'"+selectedRows[i].paySchId+"'";
			pkIds[i] = pkId;
		}
        var data = form.getData();
        data["pkIds"] = JSON.stringify(pkIds);
        data["eFlag"] = "tcgl";
		var wait_dialog = null;
		$.ajax({
			type: 'get',
			dataType:'json',
			url: '<%=path%>///ass/assTrailCarM/exportAssInfo.do',
			data:data,
			beforeSend:function(){
				wait_dialog=$.ligerDialog.SQalert({content: '正在导出信息...',SQ_type: "waitting"});
			},
			success:function(msg){
				wait_dialog.close();
				if(msg.success == 1){
					window.open(msg.data);
				}else{
					$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				}
			} 
		});
	}
	
	//获取资产表中支付标号
	function ReadExcel(){ 
		$("#paySchCds").val("");//清空支付表号组
		$.ajaxFileUpload({  
		    url : "<%=path%>/warrant/warrantfilemanage/importExcel.do",  
		    dataType : 'json',  
		    data : {},
		    secureuri : false,  
		    fileElementId :'upfile',  
		    success : function(msg) { //服务器成功响应处理函数  
		    	 if(msg.success == 1){
		    		 if(msg.data == ""){
		    			 top.$.ligerDialog.SQalert({content: "上传的EXCEL支付表编号为空",SQ_type: "success"});
		    		 }else{
// 		    			 alert(msg.data);
						 //赋值
			    		 $("#paySchCds").val(msg.data);
			    		 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
			    		 grid.reload();
		    		 }
    			 }else{
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
    			 }  
	        }  
	    });  
	}
	
	//权证名称弹框
	function applyInvoice(){
		//弹出一个窗口
		$.ligerDialog.SQopen({
            title : '权证名称',
            width: 800,
            height:500,
            //top: 100,
            url:'<%=path%>/warrant/warrantfilemanage/toCompListPage.do?multiRow='+true,
//             		<!--false,-->
            // 自定义buttons的时候 不要设置 fixButtons: true
            buttons: [
                {
                    text: "确定", cls: 'l-dialog-btn-ok', onclick:function(item, Dialog){
                    	//点击确定获取到选中的权证名称,如果没有获取到则提示
                    	if (Dialog.onOk) {
                    		var cstMap = Dialog.onOk();
//                     		alert("JSON.stringify(cstMap)="+JSON.stringify(cstMap));
                    		var kv = cstMap.keySet();
                    		var cstNms="";
                    		for(var i=0;i<kv.length;i++){
// 	                    		alert("cstMap.get(kv[i])="+cstMap.get(kv[i]));
	                    		var cstNm = cstMap.get(kv[i]);
	                    		cstNms=cstNms+"'"+cstNm+"',";
                    		}
//                     		alert("cstNms="+cstNms);
                    		if(StringUtils.isNotEmpty(cstMap.get(kv[0]))){
                    			//关闭窗口
                    			Dialog.close();
                    			//页面赋值
                    			$("#searchCodeGrpCd").val(cstNms);
                    		}else{
                    			UIUtils.alertWarning("未选择到信息,不能操作!");
                    		}
                   		
                    	}
                    }
                }, {
                    text: "取消", cls: 'l-dialog-btn-no', onclick:function(item, Dialog){
                    	if (Dialog.onCancel) {
                    		Dialog.onCancel();
                    	}
                    }
                }
            ]
        });
	}
	//下载
	 function toGetPath(contractNo){
    	$.ajax({
            type: 'post',
            dataType: 'json',
            url: '<%=path%>/esign/filSign/getPath.do?contractNo='+contractNo,
            beforeSend: function () {
                wait_dialog = $.ligerDialog.SQalert({
                    content: LogUtils.LOG_CMM_DATA_LOADING,
                    SQ_type: "waitting"
                });
            },
            success: function (msg) {
                wait_dialog.close();
                if (msg.success == 1) {
                	grid.reload($('.pcontrol input', grid.toolbar).val());//加载到当前页
                	$.ligerDialog.SQalert({content: "下载成功", SQ_type: "success"});
                    //window.open(msg.info);
                	//window.open (msg.info,'newwindow','height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
                } else {
                	$.ligerDialog.SQalert({content: "网络繁忙，请稍后再试", SQ_type: "error"});
                }
            }
        });
    }
	
</script>
</body>
</html>